﻿using System;
using System.Text;

namespace MessagePack.Formatters
{
	// Token: 0x0200005F RID: 95
	public class StringBuilderFormatter : IMessagePackFormatter<StringBuilder>
	{
		// Token: 0x0600016A RID: 362 RVA: 0x00005B1F File Offset: 0x00003F1F
		private StringBuilderFormatter()
		{
		}

		// Token: 0x0600016B RID: 363 RVA: 0x00005B27 File Offset: 0x00003F27
		public int Serialize(ref byte[] bytes, int offset, StringBuilder value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteString(ref bytes, offset, value.ToString());
		}

		// Token: 0x0600016C RID: 364 RVA: 0x00005B44 File Offset: 0x00003F44
		public StringBuilder Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new StringBuilder(MessagePackBinary.ReadString(bytes, offset, out readSize));
		}

		// Token: 0x04000053 RID: 83
		public static readonly IMessagePackFormatter<StringBuilder> Instance = new StringBuilderFormatter();
	}
}
